/*
 * Copyright 2009 SHOP.COM
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.shop.opensocial.mediated.shindig.factories;

import org.apache.shindig.auth.SecurityToken;
import com.shop.opensocial.mediated.types.SecurityTokenMediator;

/**
 * Factory for converting between Mediator type and Shindig type
 *
 * @author Jordan Zimmerman
 */
public class SecurityTokenMediatorFactory extends GenericMediatorFactory<SecurityToken, SecurityTokenMediator>
{
	public static final GenericMediatorFactoryBase<SecurityToken, SecurityTokenMediator>		i = new SecurityTokenMediatorFactory();

	@Override
	protected SecurityToken internalMake(final SecurityTokenMediator c)
	{
		return new SecurityToken()
		{
			@Override
			public String getAuthenticationMode()
			{
				return c.getAuthenticationMode();
			}

			@Override
			public String getOwnerId()
			{
				return c.getOwnerId();
			}

			@Override
			public String getViewerId()
			{
				return c.getViewerId();
			}

			@Override
			public String getAppId()
			{
				return c.getAppId();
			}

			@Override
			public String getContainer()
			{
				return c.getContainer();
			}

			@Override
			public String getDomain()
			{
				return c.getDomain();
			}

			@Override
			public String getAppUrl()
			{
				return c.getAppUrl();
			}

			@Override
			public long getModuleId()
			{
				return c.getModuleId();
			}

			@Override
			public String getUpdatedToken()
			{
				return c.getUpdatedToken();
			}

			@Override
			public String getTrustedJson()
			{
				return c.getTrustedJson();
			}

			@Override
			public boolean isAnonymous()
			{
				return c.isAnonymous();
			}
		};
	}

	@Override
	protected SecurityTokenMediator internalUnmake(final SecurityToken token)
	{
		return new SecurityTokenMediator()
		{
			@Override
			public String getAuthenticationMode()
			{
				return token.getAuthenticationMode();
			}

			@Override
			public String getContainer()
			{
				return token.getContainer();
			}

			@Override
			public String getOwnerId()
			{
				return token.getOwnerId();
			}

			@Override
			public String getViewerId()
			{
				return token.getViewerId();
			}

			@Override
			public String getAppId()
			{
				return token.getAppId();
			}

			@Override
			public String getDomain()
			{
				return token.getDomain();
			}

			@Override
			public String getAppUrl()
			{
				return token.getAppUrl();
			}

			@Override
			public long getModuleId()
			{
				return token.getModuleId();
			}

			@Override
			public String getUpdatedToken()
			{
				return token.getUpdatedToken();
			}

			@Override
			public String getTrustedJson()
			{
				return token.getTrustedJson();
			}

			@Override
			public boolean isAnonymous()
			{
				return token.isAnonymous();
			}
		};
	}

	private SecurityTokenMediatorFactory()
	{
	}
}
